package com.tanhua.server.controller;

import com.tanhua.domain.mongo.Comment;
import com.tanhua.server.service.CommentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/comments")
@Slf4j
public class CommentsController {

    @Autowired
    private CommentService commentService;


    /**
     * 接口名称：评论列表
     接口路径：GET/comments
     */
    @GetMapping
    public ResponseEntity queryCommentsList(String movementId,Integer page,Integer pagesize){
        return commentService.queryCommentsList(movementId,page,pagesize);
    }


    /**
     * 接口名称：评论-提交
     * 接口路径：POST/comments
     *
     */
    @PostMapping
    public ResponseEntity saveComments(@RequestBody Map<String,String> paramMap){
        String publishId = paramMap.get("movementId");
        String comment = paramMap.get("comment");
        return commentService.saveComments(publishId,comment);
    }
}
